Skip to content

fix(python-uv): don't crash when bytecode is on and there is no manifest - #976

Merged
bnusunny merged 1 commit into
aws:developfrom
bnusunny:fix/python-uv-bytecode-no-manifest
Nov 19, 2026
Merged

bnusunny merged 1 commit into
aws:developfrom
bnusunny:fix/python-uv-bytecode-no-manifest

Conversation

@bnusunny

Copy link
Copy Markdown
Contributor

Issue #, if available: Follow-up to #973 (bot finding)

Description of changes

With uv_compile_bytecode: true, or a truthy UV_COMPILE_BYTECODE, and no pyproject.toml or requirements.txt, the python_uv workflow raised TypeError: expected str, bytes or os.PathLike object, not NoneType while it was being set up. _uv_config_from_options called _project_name(None), and open(None) isn't an OSError.

Only uv_prune needs the project name, and it can only get that far with a pyproject.toml manifest. So the name is now read only when uv_prune is set. With no manifest the build continues without dependencies, as before #973.

Description of how you validated changes

  • Two new unit tests: no manifest with uv_compile_bytecode: True, and no manifest with UV_COMPILE_BYTECODE=1. Both fail without the fix.
  • The bot's reproduction (a requirements.txt-less function built with UV_COMPILE_BYTECODE=1) now builds and outputs app.py.
  • make lint and make black-check pass. pytest tests/unit passes (1077), and tests/integration/workflows/python_uv passes with real uv 0.13.9 (72).

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

With uv_compile_bytecode (or a truthy UV_COMPILE_BYTECODE) and no
pyproject.toml or requirements.txt, _uv_config_from_options called
_project_name(None) and raised TypeError. Only uv_prune needs the project
name, so read it only then. The build now continues without dependencies,
as before aws#973.
@bnusunny
bnusunny requested a review from a team as a code owner November 19, 2026 15:45
@bnusunny
bnusunny requested review from licjun and vicheey November 19, 2026 15:49
@aws-sam-tooling-bot

Copy link
Copy Markdown

🧪 Hands-on test: No problems observed in 7 scenarios

Commit 1ad3b1f · build LambdaToolingHandsOn-NoDocker:24e28d1d-005e-41c5-a6e8-ace314868c93. The plan's scenarios ran on an isolated build host; a problem is reported only if it reproduced at least twice. Passing scenarios show only that these checks behaved as expected, not that the change is correct.

Scenarios

Scenario Planned check Result Runner's note
S1 Main fix: no pyproject.toml or requirements.txt, build option uv_compile_bytecode=true. The base raised TypeError (expe… ✅ pass No manifest, uv_compile_bytecode=true, UV_COMPILE_BYTECODE unset. Head: logs 'No UV-compatible manifest file found ... Continuing the build without dependencies.', prints BUILD_OK, artifact has app.p…
S2 Main fix, env var path: no manifest, no uv_* options, UV_COMPILE_BYTECODE truthy (the bot's reproduction from the PR). … ✅ pass No manifest, UV_COMPILE_BYTECODE=1 (options null) and UV_COMPILE_BYTECODE=TRUE (options {build_logical_id: Fn}). Head: both BUILD_OK with app.py, EXIT=0. Base: both BUILD_FAILED TypeError ... NoneTyp…
S3 Control: no manifest with bytecode off (env unset and UV_COMPILE_BYTECODE=0) builds on both base and PR ✅ pass Control, no manifest with bytecode off (env unset/options null; UV_COMPILE_BYTECODE=0 with uv_compile_bytecode=false). BUILD_OK with app.py and EXIT=0 for both runs on head and on base.
S4 Regression guard: uv_prune naming the function's own project (different case and separator) must still be rejected now … ✅ pass pyproject.toml project 'my-func' with uv_prune ['My_Func'] (env unset) and ['my.func'] (UV_COMPILE_BYTECODE=1). Head and base both print 'BUILD_FAILED WorkflowFailedError PythonUvBuilder:Validation -…
S5 Existing config must keep working: pyproject.toml project with a dependency and uv_compile_bytecode=true, where _projec… ✅ pass pyproject.toml project depending on six==1.16.0 with uv_compile_bytecode=true, real uv 0.13.9 against PyPI on head. BUILD_OK, EXIT=0. Artifact has app.py, six.py, six-1.16.0.dist-info/ and __pycache_…
S6 Error paths next to the change: options that need pyproject.toml must still fail with the clear message (not TypeError)… ✅ pass Head: no manifest with uv_prune [six] + bytecode fails with 'Build options uv_prune need a pyproject.toml project, but this build uses no manifest' (EXIT=1); requirements.txt with uv_prune fails with…
S7 The PR's unit tests for the python_uv workflow, including the two new no-manifest tests, pass alongside the existing on… ✅ pass Head: pytest tests/unit/workflows/python_uv -k 'without_manifest or compile_bytecode or prune' gives 35 passed, 145 deselected, exit 0, including test_compile_bytecode_without_manifest_builds_without…
Runner's notes in full
  • S1: No manifest, uv_compile_bytecode=true, UV_COMPILE_BYTECODE unset. Head: logs 'No UV-compatible manifest file found ... Continuing the build without dependencies.', prints BUILD_OK, artifact has app.py, EXIT=0. Base: BUILD_FAILED TypeError expected str, bytes or os.PathLike object, not NoneType, EXIT=1. The fix works.
  • S2: No manifest, UV_COMPILE_BYTECODE=1 (options null) and UV_COMPILE_BYTECODE=TRUE (options {build_logical_id: Fn}). Head: both BUILD_OK with app.py, EXIT=0. Base: both BUILD_FAILED TypeError ... NoneType, EXIT=1.
  • S4: pyproject.toml project 'my-func' with uv_prune ['My_Func'] (env unset) and ['my.func'] (UV_COMPILE_BYTECODE=1). Head and base both print 'BUILD_FAILED WorkflowFailedError PythonUvBuilder:Validation - Build option uv_prune cannot name the project being built (my-func)', EXIT=1, and both artifact dirs stay empty. Self-name check unchanged.
  • S5: pyproject.toml project depending on six==1.16.0 with uv_compile_bytecode=true, real uv 0.13.9 against PyPI on head. BUILD_OK, EXIT=0. Artifact has app.py, six.py, six-1.16.0.dist-info/ and __pycache__/six.cpython-311.pyc, so bytecode was compiled. Head only, per plan.
  • S6: Head: no manifest with uv_prune [six] + bytecode fails with 'Build options uv_prune need a pyproject.toml project, but this build uses no manifest' (EXIT=1); requirements.txt with uv_prune fails with '... but this build uses requirements.txt' (EXIT=1); no manifest with uv_prune [] and UV_COMPILE_BYTECODE=1 gives BUILD_OK with app.py (EXIT=0). Base matches the first two and crashes on the third with TypeError ... NoneType, EXIT=1.
  • S7: Head: pytest tests/unit/workflows/python_uv -k 'without_manifest or compile_bytecode or prune' gives 35 passed, 145 deselected, exit 0, including test_compile_bytecode_without_manifest_builds_without_dependencies and test_truthy_env_without_manifest_builds_without_dependencies. Full tests/unit/workflows/python_uv: 180 passed, 53 subtests passed, exit 0.

🤖 Automated hands-on test — not a review approval · model claude-opus-5.5 · Kiro kiro-cli 2.33.1 · build LambdaToolingHandsOn-NoDocker:24e28d1d-005e-41c5-a6e8-ace314868c93 · commit 1ad3b1f

History (1)
Commit Result When (UTC) Build
1ad3b1f No problems observed 2026-11-19 15:51 LambdaToolingHandsOn-NoDocker:24e28d1d-005e-41c5-a6e8-ace314868c93

@bnusunny bnusunny mentioned this pull request Nov 19, 2026
1 task done
@bnusunny
bnusunny merged commit 4c79baa into aws:develop Nov 19, 2026
127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants